package com.hbnu.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author kittychen
 * @since 2025-10-17 16:52
 */
public class Pokers {

    public static void main(String[] args) {
        // 1、定义集合，用于存放扑克牌
        List<String> pokers = new ArrayList<>(54);

        // 2、定义扑克牌
        String[] colors = {"♠", "♥", "♣", "♦"};
        String[] numbers = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        for (String color : colors) {
            for (String number : numbers)
                pokers.add(color + number);
        }
        pokers.add("🃏King");
        pokers.add("🃏Queen");

        // 3、洗牌
        Collections.shuffle(pokers);
        // System.out.println("洗牌后的牌型：\r\n" + pokers);

        // 4、准备3个玩家和一个底牌
        List<String> player1 = new ArrayList<>(20);
        List<String> player2 = new ArrayList<>(20);
        List<String> player3 = new ArrayList<>(20);
        List<String> bottom = new ArrayList<>(3);

        // 5、发牌
        for (int i = 0; i < pokers.size(); i++) {
            if (i < 3) {
                bottom.add(pokers.get(i));
            } else if (i % 3 == 0) {
                player1.add(pokers.get(i));
            } else if (i % 3 == 1) {
                player2.add(pokers.get(i));
            } else {
                player3.add(pokers.get(i));
            }
        }

        // 6、展示牌型
        lookPokers("周润发", player1);
        lookPokers("刘德华", player2);
        lookPokers("周星驰", player3);
        lookPokers("底牌", bottom);
    }

    private static void lookPokers(String name, List<String> pokers) {
        System.out.println(name + "的牌型：");
        for (String poker : pokers) {
            System.out.print(poker + " ");
        }
        System.out.println();
    }
}
